package cn.laike.modules.dev.service.impl;

import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import cn.laike.common.utils.PageUtils;
import cn.laike.common.utils.Query;

import cn.laike.modules.dev.dao.InvoiceDao;
import cn.laike.modules.dev.entity.InvoiceEntity;
import cn.laike.modules.dev.service.InvoiceService;
import cn.laike.modules.sys.shiro.ShiroUtils;


@Service("invoiceService")
public class InvoiceServiceImpl extends ServiceImpl<InvoiceDao, InvoiceEntity> implements InvoiceService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
    	Integer hotelId = ShiroUtils.getHotelId();
        Page<InvoiceEntity> page = this.selectPage(
                new Query<InvoiceEntity>(params).getPage(),
                new EntityWrapper<InvoiceEntity>()
                .eq(ShiroUtils.isAdmin(),"uid", ShiroUtils.getUserId())
                .eq((hotelId != null && hotelId > 0), "hotel_id", hotelId)
                .orderBy("id", false)
        );

        return new PageUtils(page);
    }

}
